<%= page_title "Users" %>

<section class="clearfix">
  <%= render 'user_project_roles/search_bar', system_level: true %>

  <div class="users-csv">
    <%= link_to "Download as CSV", new_csv_export_path(format: :csv, type: :users) %>
  </div>

  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <th><%= sortable "id" %></th>
        <th><%= sortable "name" %></th>
        <th><%= sortable "email" %></th>
        <th><%= sortable "role_id", "System Level Role" %></th>
        <th></th>
      </tr>
    </thead>

    <tbody>
    <% if @users.empty? %>
      <tr>
        <td>No user was found!</td>
      </tr>
    <% else %>
        <%= render @users %>
    <% end %>
    </tbody>
  </table>

  <div class="admin-actions">
    <% if can?(:write, :users) %>
      <div class="pull-right">
        <%= link_to "New", new_user_path, class: "btn btn-default" %>
      </div>
    <% end %>

    <%= paginate @users %>
  </div>
</section>
